<?php
declare (strict_types = 1);
namespace app\middleware;
use think\Response;
use think\Config;
/**
 * 中间件：控制接口访问频次
 */
class RateLimit
{
    private $config;
    public function __construct(Config $config)
    {
        $this->config = $config->get('redis', []);
        // $this->block_ip_list = $config->get('ip.block', []);
    }
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        //Before
        // $client = new \Predis\Client('tcp://127.0.0.1:6379');
        // $responses = $client->get('foo')->execute();
        $response = $next($request);
        // After
        return $response;
    }
}
